<?php //include("html-includes/common/carousel.php"); ?>
<div class="col-md-12">
	<div class="row">
		<?php include("global-includes/breadcrumbs.php"); ?>
		<h1 class="sectionTitle"><?php echo $page["name"]; ?></h1>
		<?php echo $page["description"];?>
		
		<?php 
			$products = getCartProducts();
			
			$productCount = count($products); 
		?>
		<?php if($productCount == 0):?>
			<div class="alert alert-warning"><span class="glyphicon glyphicon-info-sign"></span> <?php echo translate("cart_no_products"); ?></div>
			<input class="btn btn-danger" value="<?php echo translate("back_to_shop"); ?>" onclick="goBack()" type="button" />
		<?php else: ?>
			<table class="table" id="cartTable">
				<thead>
					<tr>
						<th class="hidden-xs">#</th>
						<th class="hidden-xs"></th>
						<th><?php echo translate("product_name"); ?></th>
						<th><?php echo translate("quantity"); ?></th>
						<th><?php echo translate("price"); ?></th>
						<th><?php echo translate("total"); ?></th>
						<th class="hidden-xs"><?php echo translate("VAT"); ?>(<?php echo get_setting("vat");?>%)</th>
						<th class="">&nbsp;</th>
					</tr>
				</thead>
				<tbody>
					<?php $productIndex = 1; foreach($products as $product): ?>
						<tr class="productRow" id="row_<?php echo $product["stock_id"]; ?>">
							<td class="hidden-xs"><?php echo $productIndex?></td>
							<td class="hidden-xs">
								<a  title="" href="<?php echo $product["url"]; ?>">
									<img class="img-responsive" alt="" src="<?php echo scripts_url().$product["images"][0]["name"]; ?>">
								</a>
							</td>
							<td>
								<a class="uppercase" href="<?php echo $product["url"]; ?>" title="<?php echo $product["name"]; ?>">
									<?php echo $product["name"]; ?>
								</a>
							</td>
							<td>
								<div class="input-group">
						      		<input class="form-control pull-left quantityInput" style="width:50px;" product_id="<?php echo $product["id"]; ?>" stock_id="<?php echo $product["stock_id"]; ?>" min="1" max="<?php echo $product["max_quantity"];?>" initial_value="<?php echo $product["quantity"];?>" value="<?php echo $product["quantity"];?>" type="number" />
						      		<button class="btn btn-default btn-warning changeQuantity"><span class="glyphicon glyphicon-ok"></span></button>
						      		<div class="clearfix"></div>
						      		<div class="clearfix"></div>
							    </div>
							</td>
							<td><?php echo $product["price"]; ?></td>
							<td class="perTotal"><?php echo makePriceInterval($product["total_price"], 0, $settings["currency"]); ?></td>
							
							<td class="hidden-xs vat">
								<?php
									$vat = ($product["total_price"]*get_setting("vat"))/100;
									echo makePriceInterval($vat,0,get_setting("currency")); ?>
							</td>
							<td class="">
								 <button product_id="<?php echo $product["id"]; ?>" stock_id="<?php echo $product["stock_id"]; ?>" class="btn btn-default btn-danger btn-sm removeFromCart" type="button" title="<?php echo translate("remove_from_cart")?>">
						        	<span class="glyphicon glyphicon-minus-sign"></span>
						        </button>
							</td>
						</tr>
						
					<?php $productIndex++; endforeach; ?>
					<?php if(isset($products[0]["discounts"])):?>
						<?php foreach($products[0]["discounts"] as $discount): ?>
							<tr class="productRow">
								<td class="hidden-xs"><?php echo $productIndex; ?></td>
								
								<td class="hidden-xs">&nbsp;</td>
								<td>
									<?php echo translate("coupon"); ?> : <strong><?php echo $discount["coupon_code"]; ?></strong>
								</td>
								<td>1</td>
								
								<td>-<?php echo makePriceInterval($discount["value"], 0,get_setting("currency")); ?></td>
								<td class="perTotal">-<?php echo makePriceInterval($discount["value"], 0,get_setting("currency")); ?></td>
								<td class="hidden-xs vat">
								-<?php
									$vat = ($discount["value"]*get_setting("vat"))/100;
									echo makePriceInterval($vat,0,get_setting("currency")); ?>
								</td>
								<td class="">&nbsp;</td>
							</tr>
						<?php endforeach; ?>
					<?php $productIndex++; endif; ?>
					
					
					
					<?php if(isset($products[0]["reward_discount"])):?>
							<tr class="productRow">
								<td class="hidden-xs"><?php echo $productIndex; ?></td>
								
								<td class="hidden-xs">&nbsp;</td>
								<td>
									<?php echo translate("reward_points"); ?>
								</td>
								<td><?php echo $products[0]["reward_discount"]["points"]; ?></td>
								
								<td>-<?php echo makePriceInterval($settings["thankyou_value"], 0,get_setting("currency")); ?></td>
								<td class="perTotal">-<?php echo makePriceInterval($products[0]["reward_discount"]["value"], 0,get_setting("currency")); ?></td>
								<td class="hidden-xs vat">
								-<?php
									$vat = ($products[0]["reward_discount"]["value"]*get_setting("vat"))/100;
									echo makePriceInterval($vat,0,get_setting("currency")); ?>
								</td>
								<td class="">&nbsp;</td>
							</tr>
					<?php endif; ?>
					
					
					
					
					
					<tr class="checkout">
						<td class="hidden-xs">&nbsp;</td>
						<td class="hidden-xs">&nbsp;</td>
						<td colspan="5">
							<small><?php echo translate("total_products_price"); ?>: </small>
							<strong id="perTotal">
								<?php echo makePriceInterval($products[0]["products_price"], 0, $settings["currency"]); ?>
							</strong>
							<br/>
							<small><?php echo translate("transport_price"); ?>: </small>
							<strong id="transportPrice"><?php echo makePriceInterval($products[0]["transport_price"], 0, $settings["currency"]); ?></strong>
							
							<br />
							<small><?php echo translate("total_price"); ?>: </small>
							<strong id="grandTotal">
								<?php echo makePriceInterval($products[0]["grand_total"], 0, $settings["currency"]); ?>
							</strong>
	
						</td>
						<td>&nbsp;</td>
	
					</tr>
					<tr id="checkout">
						<td class="hidden-xs">&nbsp;</td>
						<td class="hidden-xs">&nbsp;</td>
						<td>
	
							<div class="input-group">
								<input value="" id="coupon_code" name="coupon_code" placeholder="add coupon" class="form-control" placeholder="<?php echo translate("add_coupon"); ?>" type="text" />
						      <span class="input-group-btn">
						        <button id="sendCoupon" class="btn btn-default btn-success" type="button"><?php echo translate("send"); ?></button>
						      </span>
						    </div>
						</td>
						<td class="hidden-xs" style="">
							<input class="btn btn-warning" value="<?php echo translate("back_to_shop"); ?>" onclick="goBack()" type="button" />
						</td>
						<td colspan="4" style="text-align:right;">
							<a href="<?php echo $site_pages["checkout"]["url"];?>" class="btn btn-danger btn-large toCheckout"><span><?php echo translate("checkout"); ?> &nbsp;&nbsp;</span> <span class="glyphicon glyphicon-shopping-cart"></span></span></a>
						</td>
					</tr>
					
				</tbody>
			</table>
		<?php endif; ?>
		
	</div>
</div>

